Skip to content

[codex] Skip core SEO routes when site routes exist#1386

Open
auggernaut wants to merge 2 commits into
emdash-cms:mainfrom
auggernaut:codex/seo-route-overrides
Open

[codex] Skip core SEO routes when site routes exist#1386
auggernaut wants to merge 2 commits into
emdash-cms:mainfrom
auggernaut:codex/seo-route-overrides

Conversation

@auggernaut

Copy link
Copy Markdown
Contributor

What does this PR do?

Skips EmDash's default root robots.txt and sitemap.xml route injection when the host Astro site already defines its own matching root route under src/pages.

This avoids duplicate static route warnings today and prevents future Astro versions from turning those duplicate root routes into hard errors. Per-collection EmDash sitemaps (/sitemap-[collection].xml) continue to be injected.

Closes: N/A

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: N/A, bug fix

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Codex GPT-5

Screenshots / test output

Validation run locally:

pnpm --silent lint:json | jq '.diagnostics | length'
# 0

pnpm lint
# passes

pnpm typecheck
# passes

pnpm --dir packages/core exec vitest run tests/unit/astro/routes.test.ts
# Test Files  1 passed (1)
# Tests  6 passed (6)

pnpm --dir packages/core typecheck
# passes

git diff --check
# passes

Before root pnpm typecheck, local package artifacts were rebuilt after refreshing node_modules:

pnpm --filter @emdash-cms/blocks build
pnpm --filter emdash build

@changeset-bot

changeset-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 06f3d4b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@auggernaut auggernaut marked this pull request as ready for review June 8, 2026 18:41
@github-actions github-actions Bot added the review/needs-review No maintainer or bot review yet label Jun 8, 2026
@auggernaut

Copy link
Copy Markdown
Contributor Author

/review

@pkg-pr-new

pkg-pr-new Bot commented Jun 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@1386

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@1386

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@1386

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@1386

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@1386

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@1386

emdash

npm i https://pkg.pr.new/emdash@1386

create-emdash

npm i https://pkg.pr.new/create-emdash@1386

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@1386

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@1386

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@1386

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@1386

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@1386

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@1386

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@1386

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@1386

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@1386

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@1386

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@1386

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@1386

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@1386

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@1386

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@1386

commit: 06f3d4b

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a clean, well-scoped bug fix. The approach—checking src/pages for existing root routes and skipping EmDash's default robots.txt/sitemap.xml injection—is sensible and fits the integration's build-time architecture. The change is additive, backwards-compatible, and includes targeted tests with good coverage of the direct-file and index.* subdirectory patterns.

I checked the diff, the routes.ts implementation, the call site in index.ts, and the new unit tests. Logic is correct, the srcDir URL-to-path conversion is done safely with fileURLToPath, and the fallback (!options.srcDir) safely defaults to injecting the routes.

One gap: ROUTE_OVERRIDE_EXTENSIONS omits .md, .mdx, and .html, which Astro also recognizes as valid page file extensions. A user with src/pages/robots.txt.md or src/pages/sitemap.xml.html would still receive duplicate-route warnings because the override check wouldn't find them. Adding those extensions would make the detection fully cover Astro's built-in page types. This is a suggestion rather than a blocker because the realistic overrides are covered.

}

const ROUTE_OVERRIDE_EXTENSIONS = [".astro", ".js", ".ts", ".jsx", ".tsx", ".mjs", ".mts"];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion] ROUTE_OVERRIDE_EXTENSIONS currently misses .md, .mdx, and .html. Astro treats all of these as valid page file extensions in src/pages, so a user with e.g. src/pages/robots.txt.md or src/pages/sitemap.xml.html would still hit duplicate-route warnings that this PR intends to avoid.

Suggested change
const ROUTE_OVERRIDE_EXTENSIONS = [".astro", ".js", ".ts", ".jsx", ".tsx", ".mjs", ".mts", ".md", ".mdx", ".html"];

@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond and removed review/needs-review No maintainer or bot review yet labels Jun 8, 2026
@github-actions github-actions Bot added review/needs-rereview Author pushed changes since the last review and removed review/awaiting-author Reviewed; waiting on the author to respond labels Jun 8, 2026
@auggernaut

Copy link
Copy Markdown
Contributor Author

/review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core review/needs-rereview Author pushed changes since the last review size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant